<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>

    </ul>
    <script>

    var arr = [{name:"张三",age:21},{name:"李四",age:20},{name:"王五",age:26},{name:"王小二",age:22}]
    // 根据数据 生成 dom元素
    var str = "";
    arr.forEach(function(item){
        str += `<li>姓名是${item.name} 年龄是${item.age}</li>`;
    })
    // console.log(str);

    // 获取ul 把 li填充到ul里
    var ulEle = document.querySelector("ul");
    document.onclick = function(){
        ulEle.innerHTML = str;
    }



    </script>
</body>
</html>